import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-10-11
 * Time: 14:05
 */
public class test3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        scanner.close();

        String[] parts = input.trim().split(",");
        int[] nums = new int[parts.length];
        for(int i=0;i<parts.length;i++){
            nums[i] = Integer.parseInt(parts[i]);
        }
        boolean result = checkSorted(nums);
        System.out.println(result);
    }

    private static boolean checkSorted(int[] nums) {
        int n = nums.length;
        if(n<=1){
            return true;
        }
        int dropCount = 0;
        for(int i=0;i<n;i++){
            if(nums[i]>nums[(i+1)%n]){
                dropCount++;
            }
        }
        return dropCount<=1;
    }
}
